package _base0to1;

/**
 * 1572. 矩阵对角线元素的和
 */
public class No1572 {
    public int diagonalSum(int[][] mat) {
        int answer = 0;
        for (int i = 0; i < mat.length; i++) {
            int right = mat[i].length - 1 - i;
            answer += mat[i][i];
            if (i != right) answer += mat[i][right];
        }
        return answer;
    }
}
